package kr.couponplay.android.domain.deal;

import kr.couponplay.android.support.HttpUtils;

public class DealDao {
	
	public String search(String url) {
		try {
			String result = HttpUtils.executeToStr(url);
			if (result.contains("exception")) {
				throw new IllegalStateException("server error");
			}
			return result;
		} catch (Exception e) {
			throw new IllegalStateException(e.getMessage(), e);
		}
	}

	public String selectAllDealList(String url) {
		try {
			String result = HttpUtils.executeToStr(url);
			if (result.contains("exception")) {
				throw new IllegalStateException("server error");
			}
			return result;
		} catch (Exception e) {
			throw new IllegalStateException(e.getMessage(), e);
		}
	}
	
	public String selectCategoryDealList(String url) {
		try {
			String result = HttpUtils.executeToStr(url);
			if (result.contains("exception")) {
				throw new IllegalStateException("server error");
			}
			return result;
		} catch (Exception e) {
			throw new IllegalStateException(e.getMessage(), e);
		}
	}
	
	public String selectNewDealList(String url) {
		try {
			String result = HttpUtils.executeToStr(url);
			if (result.contains("exception")) {
				throw new IllegalStateException("server error");
			}
			return result;
		} catch (Exception e) {
			throw new IllegalStateException(e.getMessage(), e);
		}
	}
	
	public String selectEndDealList(String url) {
		try {
			String result = HttpUtils.executeToStr(url);
			if (result.contains("exception")) {
				throw new IllegalStateException("server error");
			}
			return result;
		} catch (Exception e) {
			throw new IllegalStateException(e.getMessage(), e);
		}
	}	
	
	public String selectFreeDealList(String url) {
		try {
			String result = HttpUtils.executeToStr(url);
			if (result.contains("exception")) {
				throw new IllegalStateException("server error");
			}
			return result;
		} catch (Exception e) {
			throw new IllegalStateException(e.getMessage(), e);
		}
	}
	
	public String selectRecentViewDeals(String url) {
		try {
			String result = HttpUtils.executeToStr(url);
			if (result.contains("exception")) {
				throw new IllegalStateException("server error");
			}
			return result;
		} catch (Exception e) {
			throw new IllegalStateException(e.getMessage(), e);
		}
	}
	
	public String selectEventDeals(String url) {
		try {
			String result = HttpUtils.executeToStr(url);
			if (result.contains("exception")) {
				throw new IllegalStateException("server error");
			}
			return result;
		} catch (Exception e) {
			throw new IllegalStateException(e.getMessage(), e);
		}
	}
}
